package com.hxy.tlias.service.impl;

import com.hxy.tlias.mapper.DeptMapper;
import com.hxy.tlias.pojo.Dept;
import com.hxy.tlias.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    //查询部门列表
    public List<Dept> list(){
        return deptMapper.list();
    }
    //删除部门
    @Override
    public void delete(Integer id) {
        deptMapper.delete(id);
    }
    //新增部门
    @Override
    public void save(Dept dept) {
        //补充属性
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.save(dept);
    }
    //根据id查询部门/回显
    @Override
    public Dept getById(Integer id) {
        return deptMapper.getById(id);
    }
    // 修改部门
    @Override
    public void update(Dept dept) {
        //dept.setUpdateTime(LocalDateTime.now());
        deptMapper.update(dept);
    }

}
